<template>
  <div
    :class="{
      'table-cell': true,
      'fixed-left': fixed === 'left',
      'fixed-right': fixed === 'right',
    }"
    :title="label"
    :style="{
      'flex-basis': `${width || defaultWidth}px`,
      width: `${width || defaultWidth}px`,
    }"
    @click="$emit('click', $event)"
  >
    <div class="content">
      <slot></slot>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue, Prop } from 'vue-property-decorator'

@Component
export default class TableColumn extends Vue {
  @Prop() label!: string // 展示的内容
  @Prop() width!: number
  @Prop() defaultWidth!: number
  @Prop() fixed!: 'left' | 'right' | null
}
</script>
